home *** CD-ROM | disk | FTP | other *** search
/ Aminet 7 / Aminet 7 - August 1995.iso / Aminet / comm / net / DownloadInline.lha / DownloadInline.www
Text File  |  1995-04-09  |  6KB  |  117 lines

  1. /* Name: DownloadInline.www                                             */
  2. /* AMosaic script to download inlined images and automatically spawn    */
  3. /* the appropriate viewer, for users of ADOS 2.0/2.1                    */
  4. /* ADOS 3.0/3.1 users shouldn't need this, because datatypes handle     */
  5. /* correctly. (I think :-)                                              */
  6. /*                                                                      */
  7. /*Installation:                                                         */
  8. /* Copy it to your rexx: directory.                                     */
  9. /*                                                                      */
  10. /* Here's how this script works.  It will accept either zero or one     */
  11. /* command line argument.  If there are no command line arguments, the  */
  12. /* script will find out how many inlined images there are in the        */
  13. /* current document and display that number in the shell from which     */
  14. /* AMosaic was started.  (If you start AMosaic from the WB, I have no   */
  15. /* idea what will happen.  Try it and find out, and let me know...I'm   */
  16. /* too lazy to test it.)                                                */
  17. /* The script will accept one argument, as mentioned above.  This       */
  18. /* is the number of the inlined image you wish to access.  So, if you   */
  19. /* want the first inlined image in a page, put a 1 as the argument.     */
  20. /* Simple, eh?                                                          */
  21. /*                                                                      */
  22. /* So to use this script, select the Macro menu item from the Rexx menu */
  23. /* and enter the name of this script followed by a number (or don't     */
  24. /* give anything, and it will report how many inlined images there are) */
  25. /*                                                                      */
  26. /* I suggest that you edit the env:Mosaic/prefs file (and corresponding */
  27. /* file in envarc:) and make this script correspond to a menu hotkey.   */
  28. /* Here's what my prefs file looks like:                                */
  29. /* DelayImageLoads         true
  30.    ImageCacheSize          0
  31.    RexxMacro1      Get Inline 1 | downloadinline 1
  32.    RexxMacro2      Get Inline 2 | downloadinline 2
  33.    RexxMacro3      Get Inline 3 | downloadinline 3
  34.    RexxMacro4      Get Inline 4 | downloadinline 4
  35.    RexxMacro5      Get Inline 5 | downloadinline 5
  36.    RexxMacro6      Get Inline 6 | downloadinline 6
  37.    RexxMacro7      Get Inline 7 | downloadinline 7
  38.    RexxMacro8      Add to Hotlist | add-hotlist
  39.    RexxMacro9      Jump to Hotlist | "'jump url file://localhost/env:Mosaic/hotlist.html'"
  40.    RexxMacro10     # of Inlines | downloadinline
  41.  
  42.    As you can see, if I press lamiga-0, I will automatically get the number
  43.    of inlined images displayed in the shell.  And I have set up
  44.    lamiga-1 -> lamiga-7 to correspond to downloading that respective
  45.    inlined image.  (i.e. if I press lamiga-5, I will get the fifth inlined
  46.    image on the page, if it exists).
  47.    If there are lots of inlined images (say, for example 20 on a page),
  48.    and you want to see the 17th one, you'll have to select the Macro
  49.    menu item, and manually put 17 on the command line.
  50.  
  51.    This script does a little bit of error checking.  It makes sure there
  52.    are inlined images on the page in the first place.  It also checks
  53.    to make sure you haven't asked for an inlined image that doesn't exist.
  54.    (Well, if you enter an argument of -5, AMosaic will try and get a
  55.    non-existant file, and report an error, but the script does rudimenary
  56.    error checking.
  57.  
  58.    Caveats:
  59.     - I start AMosaic from the shell, so the say commands in this script
  60.       will output to the shell that I started from.  I have no idea what
  61.       happens when AMosaic is started from the WB and it wants to say
  62.       something.  I expect nothing will happen, in which case you can't
  63.       see how many inlined images are on the page (unless you count them
  64.       yourself. :-)
  65.     - This is not the best way to see these inline images.  It'd be much
  66.       better if one could simply click on an inlined image and have it
  67.       downloaded.  I *know* there's a way to do this, but I haven't
  68.       figured it out yet.  The main problem is I don't know alot of the
  69.       terms of the WWW (like what an anchor is).  Oh well, for the time
  70.       being, this will suffice.
  71.  
  72.     Comment or questions or suggestions or help or just rude mail can
  73.     be sent to:
  74.     tcourtna@eagle.wbm.ca
  75.  
  76.     Enjoy.
  77.  
  78.     Oh, if this doesn't work on your setup, let me know and I'll see what
  79.     I can do to fix it.
  80.  
  81.     I suppose I should also include a disclaimer.  I accept no responsibility
  82.     for the actions of this program.  Use at your own risk. (I do :-).
  83.  
  84.     Hmmm, the documentation is more than twice as long as script itself,
  85.     I suppose I should stop.                            */
  86.  
  87. /* get which inlined image to download */
  88. parse arg charnumber
  89.  
  90. /* if no argument given (i.e. no image #) get # of inlined images on page */
  91. if charnumber = ''
  92. then do
  93.     'fetch images stem='mystem
  94.     say 'Number of inlined images on this page: 'mystem.0
  95.     exit
  96.     end
  97.  
  98. options results
  99. 'fetch images stem='mystem
  100.  
  101. inlinecount = mystem.0
  102. /* make sure there are inlined images on this page */
  103. if inlinecount = 0
  104. then do
  105.     say 'No Inlined images on this page'
  106.     exit
  107.     end
  108. /* make sure user doesn't specify illegal inline image # */
  109. else if inlinecount < charnumber
  110. then do
  111.     say 'That inline image does not exist.'
  112.     say 'Pick a number <= 'inlinecount
  113.     exit
  114.     end
  115. /* valid number...get URL! */
  116. else 'jump url 'mystem.charnumber.URL
  117.